package lai;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

import java.util.*;

public class TestComparator {
  public static void main(String[] args) {
    ParallelogramComparator pc = new ParallelogramComparator();
    Triangle g1 = new Triangle(5, 3.3);
    Triangle g2 = new Triangle(6,8);
    Triangle g3= new Triangle(3,5.5);
    Triangle g4 = new Triangle(8,10);
    Triangle g5 = new Triangle(6.6,9);

    ArrayList<Triangle> list = new ArrayList<>();
    list.add(g1);
    list.add(g2);
    list.add(g3);
    list.add(g4);
    list.add(g5);
    System.out.println("升序");
    Collections.sort(list,pc);
    for (Triangle one:list) {
      System.out.println(one.getArea());
    }
    System.out.println("-------------------------------");

    Comparator<Triangle> pcre = Collections.reverseOrder(pc);
    Collections.sort(list,pcre);
    System.out.println("降序");
    for (Triangle one:list) {
      System.out.println(one.getArea());
    }
    System.out.println("-------------------------------");

    System.out.println("随机");
    Collections.shuffle(list);
    for (Triangle one:list) {
      System.out.println(one.getArea());
    }
    System.out.println("-------------------------------");

    System.out.println("最大");
    System.out.println(Collections.max(list,pc).getArea());
  }
}
